<!--全部文章-->
<template>
    <!--    <div class="allVideobox">
            <div class="videoTitle">

                <div class="size">
                    文字大小：
                    <el-select v-model="ratio" placeholder="请选择" size="mini" @change="onChange">
                        <el-option label="正常" value="1"></el-option>
                        <el-option label="1.5倍" value="1.5"></el-option>
                        <el-option label="2倍" value="2"></el-option>
                        <el-option label="2.5倍" value="2.5"></el-option>
                        <el-option label="3倍" value="3"></el-option>
                    </el-select>
                </div>

                <p class="title">{{ contentObj.articleTitle }}</p>
                <p class="timer">{{ contentObj.publishTime | formatDate("YYYY-MM-DD HH:mm") }}</p>
            </div>
            <div class="contentBox" v-html="articleContent == '' ? '暂无内容' : articleContent"></div>

            &lt;!&ndash; 热点 &ndash;&gt;
            <div class="hotmsg">
                <p class="title">
                    精彩文章推荐
                    <i class="link"></i>
                </p>
                <div class="content">
                    <div v-for="(item, index) in articleList" :key="index" class="contentItem" @click="tuijian(item)">
                        <i></i>
                        <p class="titles">{{ item.articleTitle }}</p>
                        <span class="timer">[{{ dayjs(item.publishTime) }}]</span>
                    </div>
                </div>
            </div>
        </div>-->

    <div class="container">
        <div class="main">
            <!--左侧内容开始-->
            <div class="left">
                <div class="left-head">
                    <span>文字大小</span>
                    <span class="bt" :class="{'active': ratio == 0.8}" @click="onChange(0.8)">小</span>
                    <span class="bt" :class="{'active': ratio == 1}" @click="onChange(1)">中</span>
                    <span class="bt" :class="{'active': ratio == 1.5}" @click="onChange(1.5)">大</span>
                    <span class="back" @click="onBack" v-if="isBack">返回上一页</span>
                </div>
                <div class="left-content">
                    <div class="title">{{ contentObj.articleTitle }}</div>
                    <p class="date">{{ contentObj.publishTime | formatDate("YYYY-MM-DD HH:mm") }}</p>
                    <div class="br"></div>
                    <div class="content" v-html="articleContent == '' ? content : articleContent"></div>

                    <div class="text">
                        免责声明：本终端所载数据仅供参考，若数据有误，以交易所发布数据为准，不对您 构成投资建议。
                    </div>

                    <div class="left-footer">
                        <div class="box">
                            <p class="box-text">喜欢请点个赞吧！</p>
                            <div class="box-tags">
                                <div class="box-tag" :class="{'active1': type == 1}" @click="type = 1">
                                    <i class="iconfont icon-dianzan"></i>
                                    <div class="box-tar">顶</div>
                                </div>
                                <div class="box-tag" :class="{'active2': type == 2}" @click="type = 2">
                                    <i class="iconfont icon-caishixin-"></i>
                                    <div class="box-tar">踩</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <!--左侧内容结束-->

            <!--右侧内容开始-->
            <div class="right">
                <el-image style="width: 227px; height: 175px;position: fixed;" :style="isBack ? '20px':'54px'" :src="PIC_URL + '/experience/youce_pic.png'" fit="cover"></el-image>
            </div>
            <!--右侧内容结束-->


        </div>
    </div>


</template>

<script>
import {Newdetail, queryArticleListByMap} from "../script/api";
import dayjs from "dayjs";
import {imgPath, setFontSizes} from "../utils/imgPage";

import goback from "./goback";

export default {
    components: {goback},
    data() {
        return {
            params: {
                limit: 6,
                articleType: this.articleType,
                isHighlight: "",
            },
            contentObj: {},
            articleContent: "",
            articleList: [],
            ratio: window.localStorage.getItem('ratio') || 1,
            type: '',
            content: `<div style="text-align: center;">暂无内容</div>`
        };
    },
    props: {
        newsId: {
            type: [Number,String],
            default: 0
        },
        articleType: {
            type: Number,
            default: 0
        },
        isBack: {
            type: Boolean,
            default: false
        }
    },
    mounted() {

        this.Newdetail();
        //this.queryArticleListByMap();
    },
    methods: {
        // 时间过滤
        dayjs(val) {
            if (String(val)) {
                return dayjs(val).format("MM-DD");
            } else {
                return dayjs(Number(val)).format("MM-DD");
            }
        },
        // 数据
        async Newdetail() {
            const back = await Newdetail({newsId: this.newsId});
            if (back.status == 1) {

                let content = imgPath(back.data.articleContent);
                this.articleContent = setFontSizes(content, this.ratio);
                this.contentObj = {
                    ...back.data,
                    articleContent: content
                };
            }
        },
        //文章推荐数据
        async queryArticleListByMap() {
            const back = await queryArticleListByMap(this.params);
            if (back.status == 1) {
                this.articleList = back.data;
            }
        },
        tuijian(item) {
            this.newsId = item.articleId;
            this.Newdetail();
            let scrollTop =
                document.documentElement.scrollTop ||
                window.scrollTop ||
                document.body.scrollTop;
            scrollTop = 0;
        },
        onChange(val) {
            window.localStorage.setItem('ratio', val);
            this.ratio = val;
            this.articleContent = setFontSizes(this.contentObj.articleContent, this.ratio);
        },
        onBack(){
            this.$router.back();
        }
    }
};
</script>
<style scoped lang="scss">
/deep/ * {
    font-family: '宋体', 'Helvetica Neue', 'Helvetica', 'Microsoft Yahei', sans-serif !important;
}


.container {
    width: 100%;
    overflow-x: hidden;
    padding: 20px;
    background-color: #EEF0F4;
    box-sizing: border-box;
}

.main {
    display: flex;
    flex-direction: row;

    .left {
        flex: 0 0 1;
        border: 1px solid #CFD7E5;
        margin-right: 10px;
        background-color: #ffffff;
        position: relative;
        overflow: hidden;


        .left-head {
            position: relative;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            height: 34px;
            background: #CFD7E5;
            border: 1px solid #CFD7E5;
            font-size: 14px;
            color: #333333;
            padding-left: 10px;
            box-sizing: border-box;

            .bt {
                display: inline-block;
                width: 20px;
                height: 20px;
                line-height: 20px;
                background: #FFFFFF;
                border: 1px solid #999999;
                text-align: center;
                font-size: 13px;
                color: #999999;
                margin-left: 6px;

            }

            .active {
                color: #2C7EFF;
                border: 1px solid #2C7EFF;
            }
            .back{
                position: absolute;
                right: 10px;
                top: 10px;
                cursor: pointer;
            }
        }

        .left-content {
            padding: 24px 32px 0 32px;
            /*height: 586px;
            overflow-y: auto;
            overflow-x: hidden;*/


            .title {
                text-align: center;
                font-size: 22px;
                font-weight: bold;
                color: #333333;
            }

            .date {
                text-align: center;
                font-size: 15px;
                font-weight: 400;
                color: #666666;
                margin-top: 16px;
            }

            .br {
                width: 100%;
                height: 1px;
                background-color: #E0E0E0;
                margin-top: 16px;
                margin-bottom: 16px;
            }

            .text {
                margin-top: 20px;
                font-size: 15px;
                font-weight: 400;
                color: #999999;
                line-height: 20px;
            }
            .content{
                width: 100%;
            }

            /deep/ .content img {
                /*transform-origin: 0 0;*/
                max-width: 80%;
                height: auto;
                object-fit: contain;
            }

        }

        .left-footer {
            margin-top: 16px;
            width: 100%;
            height: auto;
            border-top: 1px solid #CFD7E5;

            .box {
                margin: 16px auto 16px auto;
                width: 274px;
                height: 76px;
                background: #ECF3FF;
                border: 1px solid #64A0FF;
                border-radius: 8px;

                .box-text {
                    text-align: center;
                    font-size: 15px;
                    font-weight: 400;
                    color: #333333;
                    margin-top: 13px;
                    margin-bottom: 12px;
                }

                .box-tags {
                    display: flex;
                    flex-direction: row;
                    justify-content: center;
                    align-items: center;
                }

                .box-tag {
                    width: 83px;
                    height: 24px;
                    background: #FFFFFF;
                    border: 1px solid #CCCCCC;
                    border-radius: 4px;
                    display: flex;
                    flex-direction: row;
                    justify-content: space-between;
                    align-items: center;
                    text-align: center;
                }

                .box-tag:nth-child(1) {
                    margin-right: 30px;
                }

                .box-tar {
                    width: 44px;
                    height: 24px;
                    line-height: 24px;
                    background: #CCCCCC;
                    border: 1px solid #CCCCCC;
                    border-radius: 0px 4px 4px 0px;
                    font-size: 12px;
                    color: #333333;
                    position: relative;
                    /*right: -1px;*/
                }

                .icon-dianzan, .icon-caishixin- {
                    position: relative;
                    left: 10px;
                    color: #999999;
                }

                .active1 {
                    border: 1px solid #EA2827;

                    .box-tar{
                        background: #EA2827;
                        color: #ffffff;
                        border: 1px solid #EA2827;
                    }
                    .icon-dianzan{
                        color:#EA2827;
                    }
                }

                .active2 {
                    border: 1px solid #2C7EFF;

                    .box-tar{
                        background: #2C7EFF;
                        color: #ffffff;
                        border: 1px solid #2C7EFF;
                    }

                    .icon-caishixin-{
                        color: #2C7EFF;
                    }
                }
            }
        }
    }

    .left::-webkit-scrollbar {
        width: 10px;
    }

    .left::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background: rgba(204, 204, 204, 1);
    }
    .left::-webkit-scrollbar-track {
        border-radius: 0;
        background: rgba(238, 238, 238, 1);

    }

    .right {
        flex: 0 0 227px;
    }
}


.allVideobox {
    max-width: 1150px;
    background: transparent;
    height: 100vh;
    margin: 0 auto;

    .videoTitle {
        position: relative;
        text-align: center;
        line-height: 24px;
        border-bottom: 1px solid #000000;
        padding-top: 50px;

        .size {
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            position: absolute;
            right: 0;
            top: 16px;
            font-size: 12px;
        }

        .title {
            font-size: 30px;
            color: #333333;
        }

        .timer {
            font-size: 14px;
            color: #666666;
            margin: 18px 0 20px;
        }
    }

    .hotmsg {
        .title {
            border-bottom: 1px solid #000000;
            font-size: 18px;
            font-weight: 800;
            color: #212121;
            line-height: 36px;

            .link {
                display: block;
                width: 42px;
                height: 3px;
                background: #d72122;
                margin-bottom: -1px;
            }
        }

        .content {
            display: flex;
            height: 116px;
            flex-flow: wrap;
            justify-content: space-between;

            .contentItem {
                cursor: pointer;

                i {
                    display: inline-block;
                    width: 5px;
                    height: 5px;
                    background: #bb100f;
                    border-radius: 50%;
                    vertical-align: 5px;
                    margin-right: 14px;
                }

                .titles {
                    display: inline-block;
                    width: 309px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }

                span {
                    font-size: 16px;
                    color: #2d2d2d;
                    line-height: 56px;
                }

                .timer {
                    margin-left: 106px;
                }
            }
        }
    }
}
</style>
<style>
.contentBox {
    padding: 29px 0;
    height: 500px;
    overflow-y: scroll;
}

/*.contentBox span img {
    display: block;
    max-width: 80%;
    height: auto;
    object-fit: contain;
}*/

.contentBox p,
.contentBox p span {
    /*font-family: none;
    font-size: 18px;
    color: #333333;
    line-height: 36px;*/
}
</style>
